package com.lagou.edu.controller;

import com.lagou.edu.service.IEmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 陶肖寅
 * @version V1.0
 * <p>
 * @date 2020-05-06 13:36
 * @email fromlx@126.com
 * @Copyright © 2020-2021 城云科技(中国)有限公司
 * </p>
 */
@RestController
@RequestMapping("/email")
public class EmailController {
    @Autowired
    IEmailService emailService;
    /**
     * 发送验证码到邮箱
     * @param email 邮件
     * @param code 验证码
     * @return true|false
     */
    @GetMapping("/{email}/{code}")
    public boolean send(@PathVariable("email") String email,
                        @PathVariable("code") String code){
        try {
            emailService.sendEmail(email,code);
            return true;
        }catch (Exception e) {
            return false;
        }

    }
}
